﻿using System;
using System.Web.UI.WebControls;
using WorkOrder.Business;

namespace WorkOrder
{
    public partial class avgOrderList : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["UserID"] == null || Session["UserID"].ToString() == "")
            {
                Session.Clear();
                ClientScript.RegisterClientScriptBlock(this.GetType(), "windowhref", "<script type='text/javascript'>alert('对不起，您还没有登录系统！');window.parent.location.href='../login.aspx';</script>");
            }
            string startTime = Request.Params["f"];
            string endTime = Request.Params["t"];
            string order_type = Request.Params["order_type"];
            string product = Request.Params["product"];
            string access_mode = "";
            string process = "";
            string dept = "";
            string dsc = Request.Params["desc"];
            if (Request.Params["access_mode"] != null)
                access_mode = Server.UrlDecode(Request.Params["access_mode"]);
            if (Request.Params["process"] != null)
                process = Request.Params["process"];
            if (Request.Params["dept"] != null)
                dept = Request.Params["dept"];
            int step = 0;
            if (Request.Params["step"]!=null)
                step = Convert.ToInt32(Request.Params["step"]);
            if (!string.IsNullOrEmpty(startTime) && !string.IsNullOrEmpty(endTime) && !string.IsNullOrEmpty(order_type) && !string.IsNullOrEmpty(product)
                && !string.IsNullOrEmpty(process) && !string.IsNullOrEmpty(dept))
            {
                AvgTimeLength atl = new AvgTimeLength();
                GridView1.DataSource = atl.getAvgTimeOrderList(product, order_type, access_mode, process, dept, startTime, endTime, dsc);
                GridView1.DataBind();

            }
            if (!string.IsNullOrEmpty(startTime) && !string.IsNullOrEmpty(endTime) && !string.IsNullOrEmpty(order_type) && !string.IsNullOrEmpty(product)
                && step!=0)
            {
                AvgTimeLength atl = new AvgTimeLength();
                GridView1.DataSource = atl.getAvgTimeOrderListofStep(step, product, order_type, access_mode, startTime, endTime, dsc);
                GridView1.DataBind();
            }
        }

        #region 处理光标行颜色事件
        protected void gvReport_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowIndex >= 0)
            {
                e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor,this.style.background='#ffe3a0'");
                e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");
            }
        }
        #endregion
    }
}
